<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

<?php 
	$ci = &get_instance();
	$USER = $ci->user_entity->init('id',$ESCORT->getUserId());
	
	$weekdayArray = getScheduleInWeekData_ioc();
	$weekdaySelected = $ESCORT->getWeekdaysArray($USER->getId());
	$workingPlacesArray = explode(',', $ESCORT->getWorkingPlaceIds());
	$travelsArray = explode(',', $ESCORT->getTravelIds());
	$servesArray = explode(',', $ESCORT->getServesToIds());
	$servicesArray = explode(',', $ESCORT->getServiceIds());
	$hourMinutesArray = getHourAndMinuteOptionData_ioc();
	$workingPlacesDataArray = getWorkingPlaceData_ioc();
	$travelsDataArray = getTravelPlaceData_ioc();
	$servesDataArray = getServesToData_ioc();
	$servicesDataArray = getServicesData_ioc();
?>

<?php if( $ESCORT->getPublicSchedule() == 1 ): ?>
	<div class="escort-infor-item-wrapper">
		<div class="escort-infor-item-left">
			<span><?php echo language_translate('services_schedule');?></span>
		</div>
		<div class="escort-infor-item-right">
			<ul>
				<?php foreach($weekdayArray as $key=>$value): ?>
					<?php 
						$SCHEDULE = $ESCORT->getSchedule($ESCORT->getId(), $key);
						$from = $SCHEDULE ? $SCHEDULE->from : ''; 
						$to = $SCHEDULE ? $SCHEDULE->to : '';
					?>
					<?php if($SCHEDULE):?>
						<li>
							<span>
								<?php echo $weekdayArray[$key];?>:
								<?php echo language_translate('services_from');?> <?php echo $hourMinutesArray[$from];?>
								<?php echo language_translate('services_to');?> <?php echo $hourMinutesArray[$to];?>
							</span>
						</li>
					<?php endif; ?>
				<?php endforeach ; ?>
			</ul>
		</div>
		<div class="clear"></div>
	</div>
<?php endif; ?>

<?php if( $ESCORT->getPublicWorkingCalendar() == 1 ): ?>
	<div class="escort-infor-item-wrapper">
		<div class="escort-infor-item-left">
			<span><?php echo language_translate('services_calendar');?></span>
		</div>
		<div class="escort-infor-item-right">
			<div class="select-box">
				<?php 
					echo dayMonthYearSelectBox(0, 'servcies_day', 'services_month', 'sevices_year', array('y'), 'class="custom"' );
					echo loader_image_s('id="loading-loading-image-days-in-month" class="hidden"');
				?>
				<div id="services-date-calendar"></div>
			</div>
		</div>
		<div class="clear"></div>
	</div>
<?php endif; ?>

<?php if( $ESCORT->getPublicWorkingPlaces() == 1 ): ?>
	<div class="escort-infor-item-wrapper">
		<div class="escort-infor-item-left">
			<span><?php echo language_translate('services_working_places');?></span>
		</div>
		<div class="escort-infor-item-right">
			<span>
				<?php 
					$myWorkingArray = array();
					foreach($workingPlacesArray as $item){
						$myWorkingArray[] = $workingPlacesDataArray[$item];
					}
					echo implode(', ',$myWorkingArray);
				?>
			</span>
		</div>
		<div class="clear"></div>
	</div>
<?php endif; ?>

<?php if( $ESCORT->getPublicTravel() == 1 ): ?>
	<div class="escort-infor-item-wrapper">
		<div class="escort-infor-item-left">
			<span><?php echo language_translate('services_travels');?></span>
		</div>
		<div class="escort-infor-item-right">
			<span>
				<?php 
					$myTravelsArray = array();
					foreach($travelsArray as $item){
						$myTravelsArray[] = $travelsDataArray[$item];
					}
					echo implode(', ',$myTravelsArray);
				?>
			</span>
		</div>
		<div class="clear"></div>
	</div>
<?php endif; ?>

<?php if( $ESCORT->getPublicServesTo() == 1 ): ?>
	<div class="escort-infor-item-wrapper">
		<div class="escort-infor-item-left">
			<span><?php echo language_translate('services_serves');?></span>
		</div>
		<div class="escort-infor-item-right">
			<span>
				<?php 
					$myServesArray = array();
					foreach($servesArray as $item){
						$myServesArray[] = $servesDataArray[$item];
					}
					echo implode(', ',$myServesArray);
				?>
			</span>
		</div>
		<div class="clear"></div>
	</div>
<?php endif; ?>

<?php if( $ESCORT->getPublicServices() == 1 ): ?>
	<div class="escort-infor-item-wrapper">
		<div class="escort-infor-item-left">
			<span><?php echo language_translate('services_services');?></span>
		</div>
		<div class="escort-infor-item-right">
			<span>
				<?php 
					$myServicesArray = array();
					foreach($servicesArray as $item){
						$myServicesArray[] = $servicesDataArray[$item];
					}
					echo implode(', ',$myServicesArray);
				?>
			</span>
		</div>
		<div class="clear"></div>
	</div>
<?php endif; ?>

<script type="text/javascript">
	var YEARNOW = <?php echo date('Y',time());?>;
	$(document).ready(function() { 
		loadAsyncDaysInMonth(YEARNOW);
		$('#sevices_year').live('change',function(){
			$year = $('#sevices_year').val();
			loadAsyncDaysInMonth($year);
		});
	});	
	function loadAsyncDaysInMonth($year){
		
		$escort_id = <?php echo $ESCORT->getId();?>;
		$('#loading-loading-image-days-in-month').show();
		$('#services-date-calendar').html('');
		$.post(BASE_URI+'home/loadAsyncYearCalendar',{year:$year,escort_id:$escort_id},function(res){
			$('#loading-loading-image-days-in-month').hide();
			$('#services-date-calendar').html(res);
		});
	}
	
</script>	


